package com.klb.interceptor;

import com.klb.tools.Sessions;
import com.klb.tools.Tools;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * Created by fujia on 2016/5/30.
 */
public class LoginInterceptorUser extends AbstractInterceptor {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
    public String intercept(ActionInvocation actionInvocation) throws Exception {
        String username = (String) Sessions.getSession("username");
        Integer userId = (Integer) Sessions.getSession("userId");

        if (!Tools.objectIsNullOrNot(username) && !Tools.objectIsNullOrNot(userId)){
            return actionInvocation.invoke();
        } else {
            return Action.LOGIN;
        }

    }
}
